# -*- coding: utf-8 -*-
import os
import shutil
import codecs
import collections
import sys
import time

import datetime as d

import socket
import hashlib
import json

import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr


def get_host_ip():
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        s.connect(('8.8.8.8', 80))
        ip = s.getsockname()[0]
        s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    finally:
        s.close()
    return ip

try:
    timestamp = d.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")

    link = "http://" + get_host_ip() + ":8000/"

    print(link)

    os.system("sudo apachectl restart")
    os.system("python -m SimpleHTTPServer")

except Exception as e:
    print(e)
